import type { IRawSession } from "@/chatlog_types/IRawSession";
import { is_raw_session_item_changed } from "@/chatlog_types/is_raw_session_item_changed";
import { ListAutoWraper } from "@/utils/ListAutoWraper";
import type { Dayjs } from "dayjs";
import type { ISessionItem } from "./ISessionItem";
import type { SessionsMgr } from "./SessionsMgr";
import { session_adapter } from "./session_adapter";

export class SessionListWraper extends ListAutoWraper<ISessionItem, IRawSession> {
  readonly owner: SessionsMgr;
  constructor(owner: SessionsMgr) {
    super();
    this.owner = owner;
  }
  override is_change(a: IRawSession, b: IRawSession): boolean { return is_raw_session_item_changed(a, b); }
  override cook(raw: IRawSession, now: Dayjs) { return session_adapter(raw, now); }
  override raw(item: ISessionItem) { return item.raw; }
  override key(item: IRawSession) { return item.userName; }
}
